package Test1;

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Stream;

public class Test1 {
    public static void main(String[] args) {
        String[] provinces={"河北省", "山西省", "吉林省", "辽宁省", "黑龙江省", "陕西省",
                "甘肃省", "青海省", "山东省", "福建省", "浙江省", "台湾省", "河南省", "湖北省",
                "湖南省", "江西省", "江苏省", "安徽省", "广东省", "海南省", "四川省",
                "贵州省", "云南省", "北京市", "天津市", "上海市", "重庆市", "内蒙古自治区",
                "新疆维吾尔自治区", "宁夏回族自治区", "广西壮族自治区", "西藏自治区", "香港特别行政区", "澳门特别行政区"

        };

        long count =Arrays.stream(provinces)
                .filter(province -> province.length()==3).count();
        System.out.println("三个字的省份个数："+count);


        long count1 =Arrays.stream(provinces)
                .filter(province -> province.contains("东")||province.contains("南")|| province.contains("西")||province.contains("北"))
                .count();
        System.out.println("统计名字中包括方位名词的（东南西北）省份个数："+count1);


        Stream .of( provinces)
                .filter(province -> province.contains("东")||province.contains("南")|| province.contains("西")||province.contains("北"))
                .filter(province -> province.endsWith("省"))
                .forEach(System.out::println);

        Object[]array = Arrays.stream(provinces)
                .filter(province -> !province.endsWith("省"))
                .toArray();
        System.out.println(Arrays.toString(array)
        );
    }
}
